home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / Booting Gallery / Booting Gallery (source) / iconhack Folder / inlines.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-22  |  4.9 KB  |  174 lines  |  [TEXT/KAHL]

  1. #pragma once
  2.  
  3. // #undef SystemSevenOrLater
  4. // #define SystemSevenOrLater 1
  5.  
  6. typedef unsigned char  uchar;
  7. typedef unsigned short ushort;
  8. typedef unsigned long  ulong;
  9.  
  10. extern struct Keyboard {
  11.     short    wasted;
  12.     short    wasted2;
  13.     short    wasted3;
  14.     int command : 1;
  15.     int : 5;
  16.     int space : 1;
  17.     int tab : 1;
  18.     int : 4;
  19.     int control : 1;
  20.     int option : 1;
  21.     int capslock : 1;
  22.     int shift : 1;
  23. } keymap : 0x174;
  24.  
  25.     // this structure is useful for interpreting the fdFlags field of the FInfo structure.
  26. typedef struct {
  27.     int isAlias        : 1;
  28.     int isInvisible : 1;
  29.     int hasBundle    : 1;
  30.     int nameLocked    : 1;
  31.     int isStationery: 1;
  32.     int hasCustomIcn: 1;
  33.     int             : 1;
  34.     int wasInited    : 1;
  35.     int hasNoINITS    : 1;
  36.     int isShared    : 1;
  37.     int SwitchLaunch: 1;
  38.     int             : 1;
  39.     int color       : 3;
  40.     int             : 1;
  41. } FileFlags;
  42.  
  43. // theQDPort() is a quick way of getting the current port without having to
  44. // call GetPort.
  45.  
  46. #pragma parameter __A0 theQDPort()
  47. pascal GrafPtr theQDPort(void) = { 0x2055, 0x2050 };
  48.  
  49. // SetA4 is an inline for setting register a4 without using inline assembly.
  50. // it returns the old value of a4.
  51.  
  52. #pragma parameter __A0 SetA4(__A0)
  53. pascal void *SetA4(void *newA4) = 0xC948;
  54.  
  55. // CopyHandle is a better interface to HandToHand.
  56.  
  57. #pragma parameter __A0 CopyHandle(__A0)
  58. pascal void *CopyHandle(void *) = {0xA9E1};
  59.  
  60. // jbGetHandleSize is just GetHandleSize, without the error checks.
  61.  
  62. #pragma parameter __D0 jbGetHandleSize(__A0)
  63. pascal Size jbGetHandleSize(void *h) = 0xA025;
  64.  
  65. // HandleOf is a better interface to PtrToHand
  66.  
  67. #pragma parameter __A0 HandleOf(__A0, __D0)
  68. pascal void *HandleOf(void *, long) = {0xA9E3};
  69.  
  70. // ClearSpace is a trivial inline for clearing space out.
  71.  
  72. // ••• WARNING!  DO NOT USE THESE IF THERE IS ANY CHANCE OF CLEARING ZERO BYTES!
  73. // ••• THESE INLINES OPERATE FOR SPEED'S SAKE AND WILL CLEAR TOO MUCH SPACE IF
  74. // ••• YOU PASS ZERO.
  75.  
  76. #pragma parameter ClearSpace(__A0, __D0)
  77. pascal void ClearSpace(void *, long) = {0x4218, 0x5380, 0x62FA};
  78.  
  79. #pragma parameter ClearSpace2(__A0, __D1)
  80. pascal void ClearSpace2(void *, long) = {0x7000, 0x30C0, 0x5541, 0x62FA};
  81.  
  82. #pragma parameter ClearSpace4(__A0, __D1)
  83. pascal void ClearSpace4(void *, long) = {0x7000, 0x20C0, 0x5981, 0x62FA};
  84.  
  85. // QuickMove is faster than BlockMove for very small moves.
  86.  
  87. #pragma parameter QuickMove(__A0, __A1, __D0)
  88. pascal void QuickMove(void *from, void *to, short bytes) = {0x12D8, 0x5340, 0x62FA};
  89.  
  90. // MakeALong makes a long out of two shorts efficiently.
  91.  
  92. #pragma parameter __D0 MakeALong(__D0, __D1)
  93. pascal long MakeALong(short HiWord, short LoWord) = {0x4840, 0x3001};
  94.  
  95. // MinShort takes the minimum of two input shorts efficiently
  96.  
  97. #pragma parameter __D0 MinShort(__D0, __D1)
  98. pascal short MinShort (short a, short b) = {0xB240, 0x6E02, 0x3001};
  99.  
  100. // MaxShort takes the maximum of two input shorts efficiently
  101.  
  102. #pragma parameter __D0 MaxShort(__D0, __D1)
  103. pascal short MaxShort (short a, short b) = {0xB240, 0x6D02, 0x3001};
  104.  
  105. // jbLoWord quickly retrieves the low word of a long..
  106.  
  107. #define jbLoWord(l) ((short)(l))
  108.  
  109. // jbHiWord quickly retrieves the high word of a long..
  110.  
  111. #pragma parameter __D0 jbHiWord(__D0)
  112. pascal short jbHiWord(long Long) = {0x4840};
  113.  
  114. // jbxDelay is a better interface for Delay.
  115.  
  116. #pragma parameter __A0 jbxDelay(__A0)
  117. pascal long jbxDelay(long numTicks)
  118.     = {0xA03B}; 
  119.  
  120. // PenWhite calls PenPat(white) from QuickDraw's globals.
  121.  
  122. pascal void PenWhite(void)
  123.     =    {0x2055, 0x4868, 0xFFF8, 0xA89D};
  124.  
  125. // PenBlack calls PenPat(black) from QuickDraw's globals.
  126.  
  127. pascal void PenBlack(void)
  128.     =    {0x2055, 0x4868, 0xFFF0, 0xA89D};
  129.  
  130. // PenGray calls PenPat(gray) from QuickDraw's globals.
  131.  
  132. pascal void PenGray(void)
  133.     =    {0x2055, 0x4868, 0xFFE8, 0xA89D};
  134.  
  135. // ArrowCursor calls SetCursor(arrow) from QuickDraw's globals.
  136.  
  137. pascal void ArrowCursor(void)
  138.     =    {0x2055, 0x4868, 0xFF94, 0xA851};
  139.  
  140. // PStringMove is a quick pascal string copy using the toolbox.
  141.  
  142. #pragma parameter PStringMove(__A0,__A1)
  143. pascal void PStringMove(const void *srcPtr,void *destPtr)
  144.     = {0x7001, 0xD010, 0xA02E}; 
  145.  
  146. // QStringMove is a quick inline pascal string copy.  By not
  147. // calling BlockMove it's faster and doesn't flush the cache.
  148.  
  149. #pragma parameter QStringMove(__A0,__A1)
  150. pascal void QStringMove(const void *srcPtr,void *destPtr)
  151.     = {0x7000, 0x1010, 0x12D8, 0x51C8, 0xFFFC};
  152.  
  153. // Why HOpenResFile isn't declared this way, I don't know.
  154. // (Under System 7, HORF has its own trap)
  155.  
  156. pascal short HOpenResFile7(short vRefNum,long dirID,ConstStr255Param fileName,
  157.     char permission) = 0xA81A;
  158.  
  159. // a quicker inline for access to NumToString when you need it:
  160.  
  161. #pragma parameter iNumToString(__D0, __A0)
  162. pascal void iNumToString(long theNum, void *theString) = {0x4267, 0xA9EE};
  163.  
  164. // a quicker inline for access to StringToNum when you need it:
  165.  
  166. #pragma parameter __D0 iStringToNum(__A0)
  167. pascal long iStringToNum(void *theString) = {0x3F3C, 0x0001, 0xA9EE};
  168.  
  169. // access to __NewGestalt when you know you need to call it
  170.  
  171. #pragma parameter __D0 __NewGestalt(__D0,__A0)
  172. pascal OSErr __NewGestalt(OSType selector,ProcPtr gestaltFunction) = 0xA3AD;
  173.  
  174.